import Vue from 'vue'
import VueRouter from 'vue-router'
import Register from '../views/Register/Register.vue'
import Login from '../views/Login/Login.vue'
import Home from '../views/Home/Home.vue'
import FoodCategory from "@/views/FoodCategory/FoodCategory";
import FoodSearch from '../views/FoodSearch/FoodSearch.vue'
import FoodDetail from '../views/FoodDetail/FoodDetail.vue'
import Search from "@/views/Search/Search";
import VIP from "@/views/VIP/VIP";
import store from '../store/index'

import ShoppingCart from '../views/ShoppingCart/ShoppingCart.vue'

import Evalution from "@/views/Evaluation/Evalution";

import Payment from '../views/Payment/Payment.vue'
import PayOrder from'../views/Payment/PayOrder.vue'
import Order from '../views/Order/Order.vue'
import OrderDetail from '../views/OrderDetail/OrderDetail.vue'//订单取消 过期 没有配送信息
import OrderToPay from'../views/OrderDetail/OrderToPay.vue'//去支付界面
import OrderDelivery from '../views/OrderDetail/OrderDelivery.vue'//订单在配送中
//个人中心
import Personal from '../views/Personal/Personal.vue'
import ChangeInfo from '../views/Personal/ChangeInfo/ChangeInfo.vue'
import Address from'../views/Personal/Address/Address.vue'
import AddressEdit from'../views/Personal/Address/AddressEdit.vue'
import AddressAdd from '../views/Personal/Address/AddressAdd.vue'
import RedBag from '../views/Personal/RedBag/RedBag.vue'
import Questions from '../views/Questions/Questions.vue'


Vue.use(VueRouter)

  const routes = [
	{//主页
	  path: '/',
	  name: 'Home',
	  meta:{index:0},
	  component: Home,
	},  
  {
    path: '/register',
    name: 'Register',
    component: Register,
  },
  {
    path: '/login',
    name: 'Login',
	meta:{index:0},
    component: Login,
  },
  {
    path: '/foodsearch',
    name: 'FoodSearch',
	//meta:{index:1},
    component: FoodSearch,
  },
  {
    path: '/fooddetail',
    name: 'FoodDetail',
	//meta:{index:2},
    component: FoodDetail,
  },
  {
    path: '/foodcategory',
    name: 'FoodCategory',
    meta:{index:1},
    component: FoodCategory,
  },
  
    {
      path: '/vip',
      name: 'VIP',
  	   meta:{index:0},
      component: VIP,
    },
   
  
  {
    path: '/shoppingcart',
    name: 'ShoppingCart',
  	 meta:{index:0},
    component: ShoppingCart,
  },

    {
      path: '/evaluation',
      name: 'Evaluation',
      component: Evalution,
    },

  {//提交订单
    path: '/payment',
    name: 'Payment',
  	meta:{index:3},
    component: Payment,
  },
  {//支付页面
    path: '/payorder',
    name: 'PayOrder',
  	meta:{index:5},
    component: PayOrder,
  },
  
  {
    path: '/order',
    name: 'Order',
	 meta:{index:0},
    component: Order,
  },
  {
    path: '/orderdetail',
    name: 'OrderDetail',
  	meta:{index:4},
    component: OrderDetail,
  },
  {
    path: '/ordertopay',
    name: 'OrderToPay',
  	meta:{index:4},
    component: OrderToPay,
  },
  {
    path: '/orderdelivery',
    name: 'OrderDelivery',
  	meta:{index:4},
    component: OrderDelivery,
  },
  
  //个人中心
  {
    path: '/personal',
    name: 'Personal',
	 meta:{index:0},
    component: Personal,
	
  },
  
  	{
  		path: '/personal/changeinfo',
  		name: 'ChangeInfo',
		meta:{index:5},
  		component: ChangeInfo
  	},
	{
		path: '/personal/address',
		name: 'Address',
		meta:{index:4},
		component: Address
	},
	{
		path: '/personal/addressedit',
		name: 'AddressEdit',
		meta:{index:5},
		component: AddressEdit
	},
	{
		path: '/personal/addressadd',
		name: 'AddressAdd',
		meta:{index:5},
		component: AddressAdd
	},
	{
		path: '/personal/redbag',
		name: 'RedBag',
		meta:{index:5},
		component: RedBag
	},
	{
		path: '/personal/questions',
		name: 'Questions',
		meta:{index:5},
		component: Questions
	},
      {
          path: '/search',
          name: 'Search',
          component: Search
      }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
});

// router.beforeEach((to,from,next)=>{
//     let needLogin = ['ShoppingCart','Order'];
//     if(needLogin.indexOf(to.name) != -1){
//         if(!store.getters.getisLogin){
//             next({
//                 name: 'Login',
//             })
//         }else{
//             next();
//         }
//     }else{
//         next();
//     }

// });

export default router
